<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件处理-事件处理方法</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
    <button v-on:click="greet">Greet</button>
    <p @click="greet">这是一段文字</p>
</div>


<script>
    var app= new Vue({
        el:'#app',
        data:{
            name: 'Vue.js'
        },
        methods:{
            greet:function (event) {//event` 是原生 DOM 事件
                console.log(event);
                alert("Hi!  "+this.name);
                if(event){
                    alert(event.target.tagName);//返回的是标记。点击按钮button，点击p文字是P
                }
            }
        }
    })
</script>
</body>
</html>
